import os
from dotenv import load_dotenv
from datetime import timedelta

# Load environment variables from .env file if it exists
load_dotenv()

class Config:
    # Flask configuration
    SECRET_KEY = os.environ.get('SECRET_KEY') or 'dev-key-for-tianwei-dashboard'

    # SQLite database configuration - store in instance folder
    SQLALCHEMY_DATABASE_URI = os.environ.get('DATABASE_URL') or \
        'sqlite:///' + os.path.join(os.path.abspath(os.path.dirname(__file__)),
                                  'instance',
                                  'tianwei_dashboard.db')
    SQLALCHEMY_TRACK_MODIFICATIONS = False

    # API configuration
    API_TITLE = 'Tianwei Wire Manufacturing Dashboard API'
    API_VERSION = 'v1'

    # JWT configuration
    JWT_ACCESS_TOKEN_EXPIRES = timedelta(hours=1)  # 令牌过期时间设置为1小时
    JWT_REFRESH_TOKEN_EXPIRES = timedelta(days=30)  # 刷新令牌过期时间设置为30天

